<template>
  <el-dialog
    top="80px"
    :visible.sync="isVisible"
    :title="'网关设备 ＞详情'"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
  >
    <el-container>
      <el-main
        :style="{ 'max-height': maxHeightDialog }"
        class="container-main"
      >
        <el-row>
          <el-col :span="24">
            <t-detail
              v-if="dataList.length != 0"
              :list="dataList"
              :is-card-border="true"
            >
              <template
                v-if="item.value != ''"
                slot="createdTime"
                slot-scope="{ item }"
              >
                {{ item.value | datefmt('YYYY-MM-DD HH:mm:ss') }}
              </template>
              <template
                v-if="item.value != ''"
                slot="updatedTime"
                slot-scope="{ item }"
              >
                {{ item.value | datefmt('YYYY-MM-DD HH:mm:ss') }}
              </template>
            </t-detail>
          </el-col>
        </el-row>
      </el-main>
      <el-footer>
        <el-button
          size="medium"
          icon="el-icon-close"
          style="width: 120px"
          @click="toClose"
        >
          关闭
        </el-button>
      </el-footer>
    </el-container>
  </el-dialog>
</template>
<script>
import TDetail from '@/components/TDetail'
import dataDetailMixins from '@/mixins/data-detail-mixins'
import LivePlayer from '@liveqing/liveplayer'
export default {
  components: {
    TDetail,
    LivePlayer,
  },
  mixins: [dataDetailMixins],
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '',
    },
    params: {
      type: Object,
      default: () => {
        return {}
      },
    },
  },
  data() {
    return {
      dataList: this.getDetailList(),
      players: {
        serial: '',
        code: '',
        // videoUrl: this.params.streamUrl, // process.env.VUE_APP_VIDEO_API + 'uploads/image/vidio/222.mp4',
        videoUrl: this.params.streamUrl,
        protocol: '',
        poster: '', // 视频封面图片 String default ''
        bLoading: true, // 指示加载状态, 支持 sync 修饰符
        bCloseShow: true,
        bControls: true, // 显示播放器控制栏 Boolean default true
        bSmart: true,
        bFullscreen: true,
        closeTimer: 0,
        device_id: '',
        device_name: '',
      },
    }
  },
  computed: {
    isVisible: {
      get() {
        return this.dialogVisible
      },
      set() {
        this.toClose()
      },
    },
  },
  methods: {
    getDetailList() {
      console.log(this.params)
      const list = [
        [{ text: '所属部门', value: this.params.deptName || '-' }],
        [{ text: '所属网格', value: this.params.fullPathText || '-' }],
        [{ text: '网关名称', value: this.params.gatewayName || '-' }],
        [{ text: '网关型号', value: this.params.gatewayModel || '-' }],
        [{ text: 'ip地址', value: this.params.ipAddr || '-' }],
        [{ text: 'sn号', value: this.params.snNumber || '-' }],
        [{ text: '所在位置', value: this.params.ipAddr || '-' }],
        [{ text: '维保单位', value: this.params.maintenanceUnit || '-' }],
        [{ text: '维保电话', value: this.params.maintenancePhone || '-' }],
        [{ text: '维保联系人', value: this.params.maintenancePerson || '-' }],

        [
          {
            text: '创建时间',
            value: this.params.createdTime,
            slotName: 'createdTime',
          },
        ]
      ]
      return list
    },
    toClose() {
      this.$emit('close')
    },
  },
}
</script>
